<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title></title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/css/ceb/gift-packs.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">


    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>奖池管理 <small>添加</small></h5>
                </div>
                <div class="ibox-content">
                    <form method="post" action="/admin/permission/doCreate" class="form-horizontal">
                        {{csrf_field()}}
                        <input type="hidden" name="info[cid]" value=""/>
                        <div class="form-group  ">
                            <label class="col-sm-2 control-label">奖池名称：</label>
                            <div class="col-sm-6">
                                <div class="row">
                                    <div class="col-md-8">
                                        <input type="text" name="info[name]" value="{{ old('info')['name'] }}"
                                               placeholder="奖池名称" class="form-control">
                                        <span class="help-block m-b-none">{{$errors->first('info.name')}}</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group @if($errors->has('info.description')) has-error @endif">
                            <label class="col-sm-2 control-label">有效时间：</label>
                            <div class="col-sm-2 m-b-xs">
                                <div class="input-group">
                                    <input placeholder="开始日期" class="form-control layer-date" readonly id="start">
                                </div>
                            </div>
                            <div class="col-sm-2 m-b-xs">
                                <div class="input-group">
                                    <input placeholder="结束日期" readonly  class="form-control layer-date" id="end">
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-6 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" id="add-xj">添加现金券</button>
                                <button class="btn btn-danger" type="button" id="add-hb">添加红包</button>
                                <button class="btn btn-warning" type="button" id="add-jx">添加加息券</button>
                            </div>
                        </div>

                        <div class="ibox-title">
                            <h5>奖池<small></small></h5>
                        </div>
                        <div class="row">
                            <div class="gift-packs-container">

                            </div>

                        </div>


                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">保存内容</button>
                                <a href="javascript:void(0);" onclick="window.history.back()">
                                <button class="btn btn-white" type="button">取消</button>
                                </a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>

<script src="/js/plugins/layer/layer.min.js"></script>

<!-- iCheck -->
<script src="/js/plugins/iCheck/icheck.min.js"></script>
<!-- layerDate plugin javascript -->
<script src="/js/plugins/layer/laydate/laydate.js"></script>

<!-- 自定义js -->
<script src="/js/content.js?v=1.0.0"></script>


<script>



    $(document).ready(function () {
        var end = {
            elem: '#end',
            format: 'YYYY-MM-DD',
              min: laydate.now(),
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };
        var end2 = {
            elem: '#end2',
            format: 'YYYY-MM-DD',
             min: laydate.now(),
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {
                //start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };
        $("#start").click(function () {
            laydate(start);
        });
        $("#end").click(function () {
            laydate(end);
        });

        //复选框样式
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });


        //添加奖池 现金券
/*        $('#add-xj').click(function () {
            var _url= '/js/admin/ceb/gift-packs-template-xj.html';
            alert(_url);
            $(".gift-packs-container").load(_url,function(data){
                var xj_count_now = $('.gift-packs-container').children('._block-xj').length
                alert(xj_count_now);
                var _strhtml=data;
                alert(_strhtml);
                var reg=/NO/g;
                _strhtml=_strhtml.replace(reg,xj_count_now);
                $(".gift-packs-container").append(_strhtml);
            })
        });*/
        var time_modle = {
            /*  elem: '#jxq-effective-date-',*/
            format: 'YYYY-MM-DD',
            min: laydate.now(),
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {
                //start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };

        //添加现金券
        var count_xj = 0;
        $('#add-xj').click(function () {
            count_xj++;
            var _url= '/js/admin/ceb/gift-packs-template-xj.html?v=34afe';
            $.get( _url).success(function(data){
                var xj_count_now = $('.gift-packs-container').children('._block-xj').length
                var _strhtml=data;
                var reg=/NUMBER/g;
                _strhtml=_strhtml.replace(reg,count_xj);
                $(".gift-packs-container").prepend(_strhtml);
                $('._remove-one-ticket').click(function () {
                        $(this).parents('._block-quan').remove();
                });
                //绑定时间控件
                console.log(time_modle);
                var end = time_modle;
                /*var end = jQuery.extend(true, {},  time_modle);*/

                end['elem']='#xjq-date-'+count_xj;
                $('#xjq-date-'+count_xj).click(function (end) {
                    console.log(end);
                    laydate(end);
                });
            });
        });


        //添加加息券
        var count_jx = 0;
        $('#add-jx').click(function () {
            count_jx++;
            var _url= '/js/admin/ceb/gift-packs-template-jx.html?v=322';
            $.get( _url).success(function(data){
                var jx_count_now = $('.gift-packs-container').children('._block-jx').length
                var _strhtml=data;
                var reg=/NUMBER/g;
                _strhtml=_strhtml.replace(reg,count_jx);
                $(".gift-packs-container").prepend(_strhtml);
                //绑定移除事件
                $('._remove-one-ticket').click(function () {
                    $(this).parents('._block-quan').remove();
                });
                //绑定时间控件
                console.log(time_modle);
                var end = time_modle;
                /*var end = jQuery.extend(true, {},  time_modle);*/
                end['elem']='#jxq-effective-date-'+count_jx;
                $('#jxq-effective-date-'+count_jx).click(function (end) {
                    console.log(end);
                    laydate(end);
                });
                //绑定checkbox事件



            });
        });
        //添加红包
        var　count_hb =0;
        $('#add-hb').click(function () {
            count_hb++;
            var _url= '/js/admin/ceb/gift-packs-template-hb.html?v=2111';
            $.get(_url).success(function(data){
                var jx_count_now = $('.gift-packs-container').children('._block-hb').length
                var _strhtml=data;
                var reg=/NUMBER/g;
                _strhtml=_strhtml.replace(reg,count_hb);
                $(".gift-packs-container").prepend(_strhtml);
                $('._remove-one-ticket').click(function () {
                    $(this).parents('._block-quan').remove();
                });

            });
        });







    });
</script>

</body>

</html>
